<template>
	<view class="cg">
		<view class="top-box">
			<view class="num-list flex">
				<view class="flex flex-direction align-center flex-sub" @click="changeType(0)">
					<view class="num">{{ user.total_score }}</view>
					<view class="text">累计收益(共生值)</view>
				</view>

				<view class="line"></view>
				<view class="flex flex-direction align-center flex-sub" @click="changeType(1)">
					<view class="num">{{ user.total_user }}</view>
					<view class="text">我的团队</view>
				</view>
			</view>
		</view>
		<view class="list">
			<view v-if="type == 0" class="item flex flex-direction" v-for="(item, index) in list" :key="item.id">
				<view class="user ">
					<view class="name">
						{{ item.event_text }}
					</view>
				</view>
				<view class="margin-tb-xs text-yellow flex justify-between">
					<view class="">
						{{ item.memo }}
					</view>
					<view class="text">
						{{ item.score }}
					</view>
				</view>
				<view class="">{{ $wanlshop.timeFormat(item.createtime, 'yyyy/mm/dd hh:MM') }}</view>
			</view>
			<view v-if="type == 1" class="item flex align-center justify-between" v-for="(item, index) in list" :key="item.id">
				<view class="">
					<view class="user flex align-center justify-center">
						<image class="tx" :src="item.avatar" mode=""></image>
						<view class="name">{{ item.nickname }}</view>
					</view>
				</view>
				<view class="text">{{ item.jointime }}</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			type: 0,
			user: {},
			list: [],
			pages: 1,
			loading: false
		};
	},
	onLoad(e) {
		this.jjr();
		this.td();
	},
	async onReachBottom() {
		if (this.loading) {
			this.pages++;
			this.td();
		}
	},
	methods: {
		changeType(type) {
			this.type = type;
			this.pages = 1;
			this.list = [];
			this.td();
		},
		jjr() {
			uni.request({
				url: `/wanlshop/activity/Index/agentStatistics`,
				method: 'GET',
				success: (res) => {
					this.user = res.data;
				}
			});
		},
		td() {
			uni.request({
				url: `/wanlshop/${this.type == 0 ? 'user/scoreLogV1' : 'activity/Index/teamList'}?page=${this.pages}`,
				method: 'POST',
				data: {},
				success: (res) => {
					if (res.data.last_page > this.pages) {
						this.loading = true;
					} else {
						this.loading = false;
					}
					this.list = this.list.concat(...res.data.data);
				}
			});
		}
	}
};
</script>

<style lang="scss" scoped>
.top-box {
	background: url('@/static/images/user/money/money_bg1.png') no-repeat top center;
	background-size: 100%;
	margin-bottom: 20rpx;
}
.cg {
	min-height: 100vh;
	background-color: #fff;
	.num-list {
		display: flex;
		justify-content: space-around;
		align-items: center;
		width: 750rpx;
		height: 200rpx;
		
		.line {
			height: 100rpx;
			border: 2rpx solid rgba(0, 0, 0, 0.05);
		}

		.num {
			font-size: 34rpx;
			font-weight: 900;
			letter-spacing: 1.7rpx;
			line-height: 47.6rpx;
			color: #fff;
		}

		.text {
			font-size: 24rpx;
			font-weight: 500;
			letter-spacing: 1.2rpx;
			line-height: 33.6rpx;
			color: rgba(255, 255, 255, 0.75);
		}
	}
	.list {
		.item {
			background-color: #fff;
			padding: 20rpx;
			border-bottom: 2rpx solid rgba(39, 25, 81, 0.1);
			font-family: PingFang SC, PingFang SC;
			font-size: 30rpx;
			color: #000000;
			.user {
				font-family: PingFang SC, PingFang SC;
				.tx {
					width: 68rpx;
					height: 68rpx;
					border-radius: 50%;
					margin-right: 20rpx;
				}
				.name {
					/** 文本1 */
					font-size: 28rpx;
					font-weight: 400;
					letter-spacing: 0rpx;
					line-height: 39.2rpx;
				}
			}
			.btn {
				display: flex;
				justify-content: center;
				align-items: center;
				width: 92rpx;
				height: 48rpx;
				font-size: 24rpx;
				font-weight: 500;
				letter-spacing: 1.2rpx;
				line-height: 33.6rpx;
				color: rgba(255, 255, 255, 1);
				border-radius: 10rpx;
				background: linear-gradient(90deg, rgba(96, 69, 251, 1) 0%, rgba(170, 40, 248, 1) 100%);
			}
			.text {
				font-size: 28rpx;
				font-weight: 700;
				letter-spacing: 0rpx;
				line-height: 39.2rpx;
				color: rgba(223, 39, 233, 1);
			}
		}
	}
}
</style>
